package prictise.com.application1.suanFa;

import java.util.Stack;

import prictise.com.application1.utils.LogcatUtils;

public class StackToQueue {
  
  private final static String TAG = "StackToQueue";
  
  private Stack<Integer> stack1 = new Stack<>();
  private Stack<Integer> stack2 = new Stack<>();
  
  public static void main(String[] args) {
    StackToQueue stackToQueue = new StackToQueue();
    stackToQueue.pushCus(1);
    stackToQueue.pushCus(2);
    LogcatUtils.showDLog(TAG, stackToQueue.popCus()+"");
  }
  
  public void pushCus(int node) {
    stack1.push(node);
  }
  
  public int popCus() {
    if (stack2.empty()) {
      if (stack1.empty()) {
        throw new RuntimeException("队列为空");
      } else {
        while (!stack1.empty()) {
          stack2.push(stack1.pop());
        }
      }
    }
    return stack2.pop();
  }
  
  public boolean emptyCus() {
    return stack1.empty() && stack2.empty();
  }
}
